home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 227_01 / btrigtab.c < prev    next >
Text File  |  1988-02-07  |  768b  |  39 lines

  1. /*
  2.  *    b t r i g t a b . c
  3.  *    -------------------
  4.  *    This program prints all sine and cosine values within the range
  5.  *    0 to 360 degrees to stdout. The values are seperated by spaces,
  6.  *    whereby all sine values are printed first.
  7.  */
  8. #include <stdio.h>
  9. #include <math.h>
  10.  
  11.  
  12. #define    PI_D_180    0.017453293
  13.  
  14. void    usage(void)
  15. {
  16. fprintf(stderr, "Usage: btrigtab tab\n");
  17. fprintf(stderr, "       tab = sin or cos\n");
  18. exit(1);
  19. /*NOTREACHED*/
  20. }
  21.  
  22.  
  23. void    main(argc, argv)
  24. int    argc;
  25. char    *argv[];
  26. {
  27. float        i;
  28. register int    csin = 0;
  29.  
  30. if(argc != 2)
  31.     usage();
  32. if(!strcmp(argv[1], "sin"))
  33.     csin = 1;
  34. else if(strcmp(argv[1], "cos"))
  35.     usage();
  36. for(i = 0 ; i <= 360 ; ++i)
  37.     printf("\t\t\t%f,\n", csin ? sin(i * PI_D_180) : cos(i * PI_D_180));
  38. }
  39.